package com.zzjson.mvc.controller;

import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;

/**
 * <p>****************************************************************************</p>
 * <p><b>Copyright © 2010-2019 shuncom team All Rights Reserved<b></p>
 * <ul style="margin:15px;">
 * <li>Description : com.zzjson.mvc.controller</li>
 * <li>Version     : 1.0.0</li>
 * <li>Creation    : 2019年11月04日</li>
 * <li>@author     : zzy0_0</li>
 * </ul>
 * <p>****************************************************************************</p>
 */
@Controller
public class IndexController {
	@GetMapping("/404.html")
	public Object handlerPageNotFound(HttpStatus httpStatus, HttpServletRequest httpServletRequest, Throwable throwable) {
		HashMap<String, Object> errors = new HashMap<>();
		errors.put("statusCode", httpServletRequest.getAttribute("javax.servlet.error.status_code"));
		errors.put("servletName", httpServletRequest.getAttribute("javax.servlet.error.servlet_name"));
		errors.put("request_uri", httpServletRequest.getAttribute("javax.servlet.error.request_uri"));
		return errors;
	}

	@GetMapping("/error")
	public void error() {
		int i = 1 / 0;
	}

	@GetMapping("/noll")
	public void nop() {
		Integer i = null;
		System.out.println(i / 10);
	}

	@GetMapping("/index")
	public String index() {
		return "index";
	}
}
